<?php
class Order extends AppModel {
	var $name = 'Orders';
	
	function buildAssociationsFromIPN($post){
		$retval = array();
		
		$retval['Order']['cart_id'] = $post["custom"];		
		$retval['Order']['payment_status'] = $post["payment_status"];		
		$retval['Order']['quantity'] = $post["quantity"];		
		$retval['Order']['product_cost'] = $post["mc_gross"];
		$retval['Order']['transaction_id'] = $post["tax_id"];
      if(isset($post['num_cart_items']) && $post['num_cart_items'] > 0){        
        for($i=1;$i<=$post['num_cart_items'];$i++){
        $key = $i - 1;
        $retval['Order'][$key]['item_name'] = $post["item_name$i"];
        $retval['Order'][$key]['item_number'] = $post["item_number$i"];
        $retval['Order'][$key]['item_number'] = $post["item_number$i"];
        $retval['Order'][$key]['quantity'] = $post["quantity$i"];
        $retval['Order'][$key]['mc_shipping'] = $post["mc_shipping$i"];
        $retval['Order'][$key]['mc_handling'] = $post["mc_handling$i"];
        $retval['Order'][$key]['product_cost'] = $post["mc_gross_$i"];
        $retval['Order'][$key]['tax'] = $post["tax$i"];
        }
      }
      return $retval;
    }
    
  function cartname() {
        $cart = $this->find("first", array("conditions" => array("Cart.id" => $cartId)));
        return $cart;
    }

}
?>